Object.defineProperty(exports, "__esModule", {
  value: true
});
var LogManager = require("AA_LogManager");
var _def_ArrayUtils = function () {
  function _creator() {}
  _creator.shuffle = function (e) {
    var t;
    var o;
    var n = e.slice();
    var i = n.length;
    for (var a = i; a--;) {
      if (a !== (o = Math.floor(Math.random() * i))) {
        t = n[a];
        n[a] = n[o];
        n[o] = t;
      }
    }
    return n;
  };
  _creator.randomArray = function (e, t, o) {
    var n = [];
    var i = [];
    for (var a = t; a <= o; a++) {
      n.push(a);
    }
    for (; e > 0; e--) {
      var r = Math.floor(Math.random() * (n.length - 1));
      i.push(n[r]);
      n[r] = n[n.length - 1];
      n.pop();
    }
    return i;
  };
  _creator.randomArrayOne = function (e) {
    return e[this.randomArray(e.length, 0, e.length - 1)[this.random(0, e.length)]];
  };
  _creator.random = function (e, t) {
    var o = Math.floor(Math.random() * (t - e)) + e;
    o == t && (o -= 1);
    return o;
  };
  _creator.deepCopy = function (t) {
    var o = this;
    if (!Array.isArray(t)) {
      throw new TypeError("Input must be an array");
    }
    return t.map(function (t) {
      if (Array.isArray(t)) {
        return o.deepCopy(t);
      } else if ("object" == typeof t && null !== t) {
        return JSON.parse(JSON.stringify(t));
      } else {
        return t;
      }
    });
  };
  _creator.uniqueArray = function (e) {
    return e.filter(function (e, t, o) {
      return o.indexOf(e) === t;
    });
  };
  _creator.removeNull = function (e) {
    return e.filter(function (e) {
      return null != e;
    });
  };
  _creator.randomArrayOneProb = function (e, t) {
    if (e.length === t.length) {
      var o = [];
      for (var n = 0; n < e.length; n++) {
        var a = e[n];
        var r = t[n];
        for (var c = 0; c < r; c++) {
          o.push(a);
        }
      }
      return (o = this.shuffle(o))[this.randomArray(o.length, 0, o.length - 1)[this.random(0, o.length)]];
    }
    LogManager.LogMgr.error("随机数组与概率数组长度不一致");
  };
  _creator.getWeightRandom = function (e) {
    var t = 0;
    e.forEach(function (e) {
      return t += e;
    });
    t *= Math.random();
    for (var o = 0; o < e.length; o++) {
      if ((t -= e[o]) <= 0) {
        return o;
      }
    }
    return 0;
  };
  _creator.findCenterIndex = function (e) {
    return [Math.floor(e.length / 2), Math.floor(e[0].length / 2)];
  };
  _creator.removeEmpty = function (e) {
    return e.filter(function (e) {
      return null != e;
    });
  };
  return _creator;
}();
exports.default = _def_ArrayUtils;